<#assign object = doc.object>
package ${object.@package}.businessrules;

import redora.service.BusinessRuleViolation;
import ${object.@package}.businessrules.base.${object.@name}BusinessRulesBase;

/**
* Custom business rule implementations go here. For a business rule you must first define it
* in the object model (see <a href="http://code.google.com/p/redora/wiki/BusinessRules">the manual</a>).
* This will look something like this.
<code>
    &lt;businessRules&gt;
        &lt;businessRule number="1" javadoc="Only updates at night are allowed." attributes="myNaughtyField"&gt;
            &lt;message language="en"&gt;You are too early, come back at {0}&lt;/message&gt;
        &lt;/businessRule&gt;
    &lt;/businessRules&gt;
</code>
* The generator will generate a ruleId handle on ${object.@name}BusinessRulesBase that you can use like:
* <code>
* ${object.@name}BusinessRules.BR_[number]
* </code>
* This can be used to add a new BusinessRuleViolation. For example like this:
* <code>
  new BusinessRuleViolation(${object.@name}
        , ${object.@name}Fields.myNaughtyField
        , ${object.@name}BusinessRules.BR_1
        , BusinessRuleViolation.Action.Update));
* </code>
* As you can see the BusinessRuleViolation object makes it possible to pinpoint the
* violated rule to the end user. In the object model you can set messages (with parameters)
* in any of the languages you want to support. The ruleId handle, ${object.@name}BusinessRules.BR_1
* in this example will point to the message you have define in the model. The generator also has
* created a message object for each language you have defined in the model.<br>
* You can use ${object.@name}BusinessRules by invoking the static check() method. This method will check
* business rule violations on ${object.@name} and any related parents and children. You can also use
* the onXXX methods to check the violations on only this ${object.@name}.
* @see BusinessRuleViolation
* @author Redora (www.redora.net)
*/
public class ${object.@name}BusinessRules extends ${object.@name}BusinessRulesBase {

    /*
    * Example
    @NotNull
    public static Set<BusinessRuleViolation> onUpdate(@NotNull ${object.@name} pojo)
            throws BusinessRuleViolationException {
        Set<BusinessRuleViolation> retVal = ${object.@name}BusinessRulesBase.onUpdate(pojo);
        //for example check if the updateDate is newer then the last updateDate
        if (pojo.dirty.containsKey(${object.@name}Fields.updateDate) {
          if (pojo.dirty.get(${object.@name}Fields.updateDate) != null
                        && pojo.dirty.get(${object.@name}Fields.updateDate).compareTo(pojo.getUpdateDate() > 0) {
              retVal.add(new BusinessRuleViolation(
              ${object.@name}, ${object.@name}Fields.updateDate, BR_1, Action.Update));
          }
        }
        return retVal;
    }
    */
}
